/*
 * File:   TestItemClass.cpp
 * Author: vicror
 *
 * Created on Oct 8, 2011, 8:42:30 PM
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files
 * (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge,
 * publish, distribute, sublicense, and/or sell copies of the Software,
 * and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#include "TestItemClass.h"
#include "../Item.h"

using SearchEnginer::Item;
CPPUNIT_TEST_SUITE_REGISTRATION(TestItemClass);

TestItemClass::TestItemClass() {
}

TestItemClass::~TestItemClass() {
}

void TestItemClass::setUp() {
}

void TestItemClass::tearDown() {
}

void TestItemClass::testGeneral() {
    int index=2;
    int step=6;
    SearchEnginer::Item item(index, step);
    CPPUNIT_ASSERT(item.index() == index);
    CPPUNIT_ASSERT(item.step() == step);
    SearchEnginer::Item b(item);
    CPPUNIT_ASSERT(b.index() == index);
    CPPUNIT_ASSERT(b.step() == step);
    b = Item(7,8);
    CPPUNIT_ASSERT(b.index() == 7);
    CPPUNIT_ASSERT(b.step() == 8);


}

void TestItemClass::testLogic() {
    CPPUNIT_ASSERT(Item(2,2) == Item(2,2));
    CPPUNIT_ASSERT(Item(2,2) == 2);
    CPPUNIT_ASSERT(Item(2,2) != Item(3,2));
    CPPUNIT_ASSERT(Item(2,2) != Item(1,2));
    CPPUNIT_ASSERT(Item(2,2) != Item(2,1));
    CPPUNIT_ASSERT(Item(2,2) != Item(2,3));
    CPPUNIT_ASSERT(Item(2,2) != 3);
    CPPUNIT_ASSERT(Item(2,2) != 1);
    CPPUNIT_ASSERT(Item(2,2) > Item(2,1));
    CPPUNIT_ASSERT(Item(2,2) > Item(1,2));
    CPPUNIT_ASSERT(!(Item(2,2) > Item(2,2)));
    CPPUNIT_ASSERT(Item(2,2) > 1);
    CPPUNIT_ASSERT(!(Item(2,2) > 2));
    CPPUNIT_ASSERT(Item(2,2) < Item(2,3));
    CPPUNIT_ASSERT(Item(2,2) < Item(3,2));
    CPPUNIT_ASSERT(!(Item(2,2) < Item(2,2)));
    CPPUNIT_ASSERT(Item(2,2) < 3);
    CPPUNIT_ASSERT(!(Item(2,2) < 2));
    CPPUNIT_ASSERT(Item(2,2) < Item(3,2));

    CPPUNIT_ASSERT(Item(2,2) >= Item(2,1));
    CPPUNIT_ASSERT(Item(2,2) >= Item(1,2));
    CPPUNIT_ASSERT(Item(2,2) >= Item(2,2));
    CPPUNIT_ASSERT(Item(2,2) >= 1);
    CPPUNIT_ASSERT(Item(2,2) >= 2);
    CPPUNIT_ASSERT(Item(2,2) <= Item(2,3));
    CPPUNIT_ASSERT(Item(2,2) <= Item(3,2));
    CPPUNIT_ASSERT(Item(2,2) <= Item(2,2));
    CPPUNIT_ASSERT(Item(2,2) <= 3);
    CPPUNIT_ASSERT(Item(2,2) <= 2);

    CPPUNIT_ASSERT(Item(2,2).isEqualWithMix(Item(2,3), 1));
    CPPUNIT_ASSERT(Item(2,2).isEqualWithMix(Item(2,2), 0));
    CPPUNIT_ASSERT(Item(2,2).isEqualWithMix(Item(2,1), -1));
    CPPUNIT_ASSERT(!Item(2,2).isEqualWithMix(Item(2,2), 1));

}
